<template>
	<view>
		<view class="wrap">
			<u-swiper :list="list" :effect3d="true"></u-swiper>
		</view>
		<view>{{num}}</view>
		<button @click="set">点击同步本地存储</button>
		<button @click="get">点击同步取得本地存储</button>
		<button @click="set2">点击异步本地存储</button>
		<button @click="get2">点击异步取得本地存储</button>
	</view>
</template>

<script>
	import {getPost} from "../../api/index/index"
	export default {
		data() {
			return {
				list: [],
				num:0
			}
		},
		onLoad() {
			getPost("/api/cms/article/open/banner/list").then(res=>{
				console.log(res)
				res.data.rows.forEach(item=>{
					console.log(item.bannerImgUrl)
					this.list.push(
						{
							image:item.bannerImgUrl,
							title:this.list.length+1
						}
					)
					// console.log(this.list)
				})
			})
		},
		methods: {
			set(){
				uni.setStorageSync("key",112)
				
			},
			get(){
				this.num=uni.getStorageSync("key")
				
			},
			set2(){
				uni.setStorage({
					key:"id",
					data:333
				})
			},
			get2(){
				uni.getStorage({
					key:"id",
					success(res){
						console.log(res.data)
 					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 40rpx;
	}
</style>
